﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoBackupDatabase.DAL
{
    using System.Data;
    using System.Data.SqlClient;

    using AutoBackupDatabase.DBConection;

    public class ReportDAL
    {
          private DbConnection conn;
          public ReportDAL()
        {
            conn = new DbConnection();
        }


          public DataTable BAOCAOTONGHOP(DateTime FROM, DateTime TO)
        {
            string query = string.Format("exec BAOCAOTONGHOP @FROM,@TO");

            SqlParameter[] sqlParameters = new SqlParameter[2];
            sqlParameters[0] = new SqlParameter("@FROM", SqlDbType.Date);
            sqlParameters[0].Value = FROM.ToShortDateString();
            sqlParameters[1] = new SqlParameter("@TO", SqlDbType.Date);
            sqlParameters[1].Value = TO.ToShortDateString();

            DataTable ds = conn.executeSelectQuery(query, sqlParameters);
              return ds;
        }

          public DataTable BAOCAODOANHTHUTHEOHOADON(DateTime FROM, DateTime TO)
          {
              string query = string.Format("exec BAOCAODOANHTHUTHEOHOADON @FROM,@TO");

              SqlParameter[] sqlParameters = new SqlParameter[2];
              sqlParameters[0] = new SqlParameter("@FROM", SqlDbType.Date);
              sqlParameters[0].Value = FROM.ToShortDateString();
              sqlParameters[1] = new SqlParameter("@TO", SqlDbType.Date);
              sqlParameters[1].Value = TO.ToShortDateString();
   

              DataTable ds = conn.executeSelectQuery(query, sqlParameters);
              return ds;
          }

          public DataTable GETLISTEXPORT(DateTime FROM, DateTime TO, bool ISPAYALL)
          {
              string query = string.Format("exec GETLISTEXPORT @FROM,@TO,@ISPAYALL");

              SqlParameter[] sqlParameters = new SqlParameter[3];
              sqlParameters[0] = new SqlParameter("@FROM", SqlDbType.Date);
              sqlParameters[0].Value = FROM.ToShortDateString();
              sqlParameters[1] = new SqlParameter("@TO", SqlDbType.Date);
              sqlParameters[1].Value = TO.ToShortDateString();
              sqlParameters[2] = new SqlParameter("@ISPAYALL", SqlDbType.Bit);
              sqlParameters[2].Value = ISPAYALL;

              DataTable ds = conn.executeSelectQuery(query, sqlParameters);
              return ds;
          }

          public DataTable BAOCAODOANHTHUTHEOMONAN(DateTime FROM, DateTime TO)
          {
              string query = string.Format("exec BAOCAODOANHTHUTHEOMONAN @FROM,@TO");

              SqlParameter[] sqlParameters = new SqlParameter[2];
              sqlParameters[0] = new SqlParameter("@FROM", SqlDbType.Date);
              sqlParameters[0].Value = FROM.ToShortDateString();
              sqlParameters[1] = new SqlParameter("@TO", SqlDbType.Date);
              sqlParameters[1].Value = TO.ToShortDateString();

              DataTable ds = conn.executeSelectQuery(query, sqlParameters);
              return ds;
          }
          public DataTable BAOCAODOANHTHUTHEONGAY(DateTime FROM, DateTime TO)
          {
              string query = string.Format("exec BAOCAODOANHTHUTHEONGAY @FROM,@TO");

              SqlParameter[] sqlParameters = new SqlParameter[2];
              sqlParameters[0] = new SqlParameter("@FROM", SqlDbType.Date);
              sqlParameters[0].Value = FROM.ToShortDateString();
              sqlParameters[1] = new SqlParameter("@TO", SqlDbType.Date);
              sqlParameters[1].Value = TO.ToShortDateString();

              DataTable ds = conn.executeSelectQuery(query, sqlParameters);
              return ds;
          }
         
    }
}
